<template>
    <div class="header">
        <div class="header-left">
            <div class="iconfont back-icon">&#xe682;</div>
        </div>
        <div class="header-input">
            <span class="iconfont">&#xe611;</span>
            输入城市/景点/游玩主题
        </div>
        <!-- router-link路由跳转  router-link自带了a标签，就是自带了默认样式 -->
        <router-link to='/city'>
            <div class="header-right">
                <!-- vuex获取传值 -->
                <!-- {{this.$store.state.city}} -->
                {{this.city}}
                <span class="iconfont arrow-icon">&#xe64a;</span>
            </div>
        </router-link>
    </div>
</template>

<script>
    // vuex给我们提供了高级API
    import { mapState, mapGetters }  from 'vuex'
    export default{
        name: 'HomeHeader',
        // props: {
        //     city: String
        // }
        computed: {
            // 使用展开运算符  可以写成数组
            ...mapState(['city']),
            ...mapGetters(['doubleCity'])
        },
    }
</script>
// 这个css样式只对当前组件有效果设置scoped，不去影响其他组件的header布局
<style lang='stylus'scoped>
    //样式里面引入样式要用@   引入css样式要在前面加上波浪线
    @import '~styles/varibles.styl' 
    .header
        display: flex
        line-height: $headerHeight
        background: $bgColor
        color: #fff
        .header-left
            width: .64rem
            float: left
            .back-icon
                text-align: center
                font-size: .4rem
        .header-input
            flex: 1
            height: .64rem
            line-height: .64rem
            background: #fff
            border-radius: .1rem
            margin-top: .12rem
            margin-left: .2rem
            padding-left: .2rem
            color: #ccc
        .header-right
            min-width: 1.04rem
            padding: 0 .1rem
            float: right
            text-align: center
            color: #fff
            .arrow-icon
                margin-left: -.04rem
                font-size: .24rem
</style>
